package com.surprise.base.util;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * PatternUtils
 * @author nick
 * 2014年9月25日
 */
public class PatternUtils {
    public static boolean match(String s, String pattern) {
        return Pattern.matches(pattern, s);
    }

    public static List<String> get(String s, String pattern) {
        Pattern p = Pattern.compile(pattern);
        Matcher matcher = p.matcher(s);

        while (matcher.find()) {
            System.out.println(matcher.group());
        }
        return null;
    }

    public static void main(String args[]) {
        String regex = "(\\d{2}):(\\d{2})";
        String s = "09:02";

        if (match(s, regex)) {
            get(s, regex);
        }
    }
}
